package com.wyt.controller;

import com.wyt.dao.EmployeeMapper;
import com.wyt.until.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: 修改员工登陆密码
 * @description:
 * @author: 王一同
 * @create: 2021-11-27 14:41
 **/

@RestController
public class PassWordController {
    @Autowired
    private EmployeeMapper empMapper;

    /**
    	* @Description:    获取ename password 更改登录密码
    	* @Author:         wyt
    	* @CreateDate:     2021/11/27 15:07
        * @UpdateRemark:   特殊说明
    	*/

    @RequestMapping("password")
    public CommonResult password(String e_password,String eNumber,String eName,String new_password){
        System.out.println(e_password+" "+eName+" "+eNumber+" "+new_password);
        Integer epassword = empMapper.selectByNameandNumber(eNumber,eName);
        System.out.println(epassword);
        CommonResult commonResult = new CommonResult();
        if(e_password.equals(String.valueOf(epassword))){
            int xgmm = empMapper.xgmm(eNumber, new_password);
            if(xgmm>=1){
                commonResult.setCode(200);
                commonResult.setMsg("修改成功");
                return commonResult;
            }else{
                commonResult.setCode(500);
                commonResult.setMsg("修改失败");
                return commonResult;
            }
        }else{
            commonResult.setCode(500);
            commonResult.setMsg("旧密码错误");
            return commonResult;
        }


    }
}
